<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('人员日报')"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="report-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                名字：<input type="text" name="staffName"/>
                            </li>
                            <li>
                                岗位：<input type="text" name="staffStation"/>
                            </li>
                            <li>
                                在位情况：<select name="staffStatus">
                                <option value="">请选择在位情况</option>
                                <option value="在岗">在岗</option>
                                <option value="出差">出差</option>
                                <option value="请假">请假</option>
                                <option value="调休">调休</option>
                            </select>
                            </li>
                            <li class="select-time">
                                <label>时间范围： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="startTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="updateTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="system:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/report";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/delete",
            clickToSelect: true,//是否启用点击选中行
            exportUrl: prefix + "/export",
            modalName: "日报",
            columns: [{
                checkbox: true
            },
                {
                    field: 'reportId',
                    title: '日报编号'
                },
                {
                    field: 'staffName',
                    title: '员工名字'
                },
                {
                    field: 'staffStation',
                    title: '员工岗位'
                },
                {
                    field: 'staffStatus',
                    title: '在位情况'
                },
                {
                    field: 'todayPlan',
                    title: '今日计划'
                },
                {
                    field: 'finishWork',
                    title: '已完成事项'
                },
                {
                    field: 'notDoWork',
                    title: '未完成事项'
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    field: 'staffProgress',
                    title: '工作进度',
                },
                {
                    field:'flag',
                    title:'是否更新',
                    formatter:function (value,row,index){
                        if (value == "1"){
                            return "是";
                        }else{
                            return "否";
                        }
                    }
                }]
        };
        $.table.init(options);
    });

    function exportExcel(formId){
        $.modal.alertWarning("将对搜索内容进行导出");

        var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
        var params = $.common.formToJSON(currentId);
        // $.bttTable.bootstrapTreeTable('refresh', params);
        console.log(params)

        $.ajax({
            url:prefix+"/export",
            data:params,
            type:"post",
            datatype: "json",
            success:function (result){
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();

            }
        })



        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {

            return;
        }
        // var url= prefix+'/reportExport';
        // $.modal.open("导出设置",url)

    }
</script>
</body>
</html>